


//
//  NQiuzhiThirdStepViewController.m
//  nncloud
//
//  Created by macfai on 2018/12/14.
//  Copyright © 2018 macfai. All rights reserved.
//

#import "NQiuzhiThirdStepViewController.h"
#import "UITextView+PlaceHolder.h"

@interface NQiuzhiThirdStepViewController ()<UITextViewDelegate>

@property (weak, nonatomic) IBOutlet UITextView *textView;

@property (nonatomic,copy)NSString *content;


@end

@implementation NQiuzhiThirdStepViewController


- (void)viewDidLoad {
    
    [super viewDidLoad];
    self.view.backgroundColor = kWhiteColor;
    [self.navigationItem setItemWithTitle:@"求职信息" textColor:kNavigationTitleColor fontSize:18 itemType:center];
    [self addNavgationRightButtonWithFrame:CGRectMake(0, 0, 40, 35) title:@"保存" Image:nil selectedIMG:nil tartget:self action:@selector(save)];
    self.textView.placeholder = @"请输入自我介绍（不大于500字）";
    self.textView.delegate = self;
    ///add 之后才能update 必须先添加然后再更新信息，目前后台是这样设计的
    //[self addJobSeeker];
    // Do any additional setup after loading the view from its nib.
}

#pragma mark - textView delegate
- (void)textViewDidChange:(UITextView *)textView{
    
    if (textView.text.length > 500 && textView.markedTextRange == nil){
//        UIAlertView * alert=[[UIAlertView alloc] initWithTitle:@"提示" message:@"字符个数不能大于50" delegate:nil cancelButtonTitle:@"返回" otherButtonTitles: nil];
//        [alert show];
        textView.text = [textView.text substringToIndex:500];
    }
}


- (void)textViewDidEndEditing:(UITextView *)textView{
    
    self.content = textView.text;
    
}





- (void)save{
    //保存 三元运算符的简写方式防止崩溃
    [NUserModel shareInstance].isDifferentRequest = YES;
    NSDictionary *dic = @{@"resumeUserId":[NUserModel shareInstance].userInfoId?:@"",
                          @"resumeName":[NGlobalModel shareInstance].name?:@"",
                          @"resumeSex":[NGlobalModel shareInstance].gender?:@"",
                          @"resumeBirthday":[NGlobalModel shareInstance].birth?:@"",
                          @"resumeMarriage":[NGlobalModel shareInstance].marriage?:@"",
                          @"resumeHeight":[NGlobalModel shareInstance].height?:@"",
                          @"resumeBodyWeight":[NGlobalModel shareInstance].weight?:@"",
                          @"resumePlace":[NGlobalModel shareInstance].region?:@"",
                          @"resumePhone":[NGlobalModel shareInstance].phone?:@"",
                          @"resumeEmail":[NGlobalModel shareInstance].email?:@"",
                          @"resumeEducation":[NGlobalModel shareInstance].xueli?:@"",
                          @"resumeSchool":[NGlobalModel shareInstance].school?:@"",
                          @"resumeProfession":[NGlobalModel shareInstance].profession?:@"",
                          @"resumeWorkNature":[NGlobalModel shareInstance].jobProperty?:@"",
                          @"resumeWorkExperience":[NGlobalModel shareInstance].experince?:@"",
                          @"resumeIndustryIntention":[NGlobalModel shareInstance].industryWill?:@"",
                          @"resumeJobIntention":[NGlobalModel shareInstance].jobWill?:@"",
                          @"resumeProfessionalSkill":[NGlobalModel shareInstance].skill?:@"",
                          @"resumeSalary":[NGlobalModel shareInstance].salary?:@"",
                          @"resumeJobStatus":[NGlobalModel shareInstance].jobStatus?:@"",
                          @"resumeIntroduction":self.content?:@"",};
    
    ///修改请求设置 修改发送编码方式
    [NNetworkClient postRequestWithBaseUrl:kResumeUpdataUrl setParameters:dic success:^(id responseObject) {
        
        YYLog(@"%@",responseObject);
        if ([responseObject[@"code"]integerValue]==0) {
            [AFToast showText:responseObject[@"msg"]];
            [self.navigationController popToRootViewControllerAnimated:YES];
        }
         [NUserModel shareInstance].isDifferentRequest = YES;
    } fail:^(NSError *error) {
        
        YYLog(@"%@",error);
         [NUserModel shareInstance].isDifferentRequest = NO;
        
    } delegater:nil];
    
    
//    [[NNRCNetRequest manager]postWithUrl:kResumeUpdataUrl params:dic success:^(id result) {
//
//        YYLog(@"%@",result);
//
//    } failure:^(id failure) {
//
//        YYLog(@"%@",failure);
//
//    }];
    
    
}




@end
